package com.freak.wanandroid.model.home.adapter;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.freak.wanandroid.R;
import com.freak.wanandroid.bean.ArticleListBean;

import java.util.List;

public class HomePageAdapter extends BaseQuickAdapter<ArticleListBean.Datas, BaseViewHolder> {

    public HomePageAdapter(int layoutResId, @Nullable List<ArticleListBean.Datas> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(@NonNull BaseViewHolder baseViewHolder, ArticleListBean.Datas data) {
        baseViewHolder.setText(R.id.home_item_title, data.getTitle());
        baseViewHolder.setText(R.id.home_item_author, data.getAuthor());
        baseViewHolder.setText(R.id.home_item_classify, data.getSuperChapterName());
        baseViewHolder.setText(R.id.home_item_time, data.getNiceDate());
        baseViewHolder.getView(R.id.home_item_img).setSelected(data.getCollect());
        baseViewHolder.addOnClickListener(R.id.ll_item);
        baseViewHolder.addOnClickListener(R.id.home_item_collect);
    }
}
